
package com.huizhan.web.dao;
 
import org.springframework.data.domain.*;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.*;
import com.huizhan.web.model.*;


@Repository 
public interface TicketTypeDao extends JpaRepository<TicketType,Long>
{
    
    /**
     * 分页查票种集合
     * @param name 名称
     * @param project_Id 项目ID
     * @param pageable 分页参数
     * @return 票种集合
     */
    @Query(
        value = "SELECT * FROM ticket_type"
            + " WHERE (name LIKE CONCAT('%',?1,'%') OR ?1  = '')"
            + " AND (project_Id =?2 OR ?2  = '') ", 
        countQuery = "SELECT COUNT(1) FROM ticket_type"
            + " WHERE (name LIKE CONCAT('%',?1,'%') OR ?1  = '')"
            + " AND (project_Id =?2 OR ?2  = '' )",
        nativeQuery = true
    )
    Page<TicketType> findByWhere(String name,String project_Id, Pageable  pageable);
    
    /**
     * 根据项目ID获取类型集合
     * @param projectId 项目ID
     * @return 类型集合
     */
    List<TicketType> findByProjectId(String projectId);
    
    /**
     * 根据项目ID和名称获取票类型集合
     * @param name 名称
     * @param projectId 项目类型ID
     * @return 票类型集合
     */
    TicketType findByProjectIdAndName(String projectId,String name);
    
     /**
      * 根据项目id获取票类型数量
      * @param projectId  项目id
      * @return 数量
      */
      Integer countByProjectId(String projectId);
    
    
}
